﻿namespace ICMRemoteEdu.Forms
{
    using ICMRemoteEdu.Properties;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class ICMDictionary : Form
    {
        private ToolStripMenuItem btnAdd;
        private Button btnCancelCompany;
        private ToolStripMenuItem btnDel;
        private ToolStripMenuItem btnEdit;
        private Button btnSaveCompany;
        private ContextMenuStrip cmCompany;
        private IContainer components;
        private ImageList ContextIcons;
        private Info Dictionary;
        private Label label1;
        private ListBox lbCompany;
        private TabPage tabCompany;
        private TabControl tabControl1;
        private TabPage tabUser;

        public ICMDictionary(Info ds)
        {
            this.InitializeComponent();
            this.Dictionary = ds;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            string item = this.ShowEditWindow(string.Empty);
            if (string.Empty != item)
            {
                this.lbCompany.Items.Add(item);
                DataRow row = this.Dictionary.Tables["Company"].NewRow();
                row["Name"] = item;
                this.Dictionary.Tables["Company"].Rows.Add(row);
            }
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
        }

        private void btnSaveCompany_Click(object sender, EventArgs e)
        {
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ICMDictionary));
            this.tabControl1 = new TabControl();
            this.tabCompany = new TabPage();
            this.btnSaveCompany = new Button();
            this.btnCancelCompany = new Button();
            this.label1 = new Label();
            this.lbCompany = new ListBox();
            this.cmCompany = new ContextMenuStrip(this.components);
            this.btnAdd = new ToolStripMenuItem();
            this.btnEdit = new ToolStripMenuItem();
            this.btnDel = new ToolStripMenuItem();
            this.Dictionary = new Info();
            this.tabUser = new TabPage();
            this.ContextIcons = new ImageList(this.components);
            this.tabControl1.SuspendLayout();
            this.tabCompany.SuspendLayout();
            this.cmCompany.SuspendLayout();
            this.Dictionary.BeginInit();
            base.SuspendLayout();
            this.tabControl1.Controls.Add(this.tabCompany);
            this.tabControl1.Controls.Add(this.tabUser);
            this.tabControl1.Dock = DockStyle.Fill;
            this.tabControl1.Location = new Point(0, 0);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new Size(0x21b, 390);
            this.tabControl1.TabIndex = 0;
            this.tabCompany.Controls.Add(this.btnSaveCompany);
            this.tabCompany.Controls.Add(this.btnCancelCompany);
            this.tabCompany.Controls.Add(this.label1);
            this.tabCompany.Controls.Add(this.lbCompany);
            this.tabCompany.Location = new Point(4, 0x16);
            this.tabCompany.Name = "tabCompany";
            this.tabCompany.Padding = new Padding(3);
            this.tabCompany.Size = new Size(0x213, 0x16c);
            this.tabCompany.TabIndex = 0;
            this.tabCompany.Text = "Учреждения";
            this.tabCompany.UseVisualStyleBackColor = true;
            this.btnSaveCompany.Location = new Point(0x16f, 0x14f);
            this.btnSaveCompany.Name = "btnSaveCompany";
            this.btnSaveCompany.Size = new Size(0x4b, 0x17);
            this.btnSaveCompany.TabIndex = 5;
            this.btnSaveCompany.Text = "Сохранить";
            this.btnSaveCompany.UseVisualStyleBackColor = true;
            this.btnSaveCompany.Click += new EventHandler(this.btnSaveCompany_Click);
            this.btnCancelCompany.Location = new Point(0x1c0, 0x14f);
            this.btnCancelCompany.Name = "btnCancelCompany";
            this.btnCancelCompany.Size = new Size(0x4b, 0x17);
            this.btnCancelCompany.TabIndex = 4;
            this.btnCancelCompany.Text = "Отмена";
            this.btnCancelCompany.UseVisualStyleBackColor = true;
            this.label1.AutoSize = true;
            this.label1.Location = new Point(8, 3);
            this.label1.Name = "label1";
            this.label1.Size = new Size(130, 13);
            this.label1.TabIndex = 1;
            this.label1.Text = "Справочник учреждений";
            this.lbCompany.ContextMenuStrip = this.cmCompany;
            this.lbCompany.FormattingEnabled = true;
            this.lbCompany.Location = new Point(11, 0x13);
            this.lbCompany.Name = "lbCompany";
            this.lbCompany.Size = new Size(0x200, 0x12f);
            this.lbCompany.TabIndex = 0;
            this.cmCompany.Items.AddRange(new ToolStripItem[] { this.btnAdd, this.btnEdit, this.btnDel });
            this.cmCompany.Name = "cmCompany";
            this.cmCompany.Size = new Size(0x9b, 70);
            this.btnAdd.Image = Resources.add;
            this.btnAdd.Name = "btnAdd";
            this.btnAdd.Size = new Size(0x9a, 0x16);
            this.btnAdd.Text = "Добавить";
            this.btnAdd.Click += new EventHandler(this.btnAdd_Click);
            this.btnEdit.Image = (Image) manager.GetObject("btnEdit.Image");
            this.btnEdit.Name = "btnEdit";
            this.btnEdit.Size = new Size(0x9a, 0x16);
            this.btnEdit.Text = "Редактировать";
            this.btnEdit.Click += new EventHandler(this.btnEdit_Click);
            this.btnDel.Image = (Image) manager.GetObject("btnDel.Image");
            this.btnDel.Name = "btnDel";
            this.btnDel.Size = new Size(0x9a, 0x16);
            this.btnDel.Text = "Удалить";
            this.Dictionary.DataSetName = "Info";
            this.Dictionary.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;
            this.tabUser.Location = new Point(4, 0x16);
            this.tabUser.Name = "tabUser";
            this.tabUser.Padding = new Padding(3);
            this.tabUser.Size = new Size(0x213, 0x16c);
            this.tabUser.TabIndex = 1;
            this.tabUser.Text = "Пользователи";
            this.tabUser.UseVisualStyleBackColor = true;
            this.ContextIcons.ColorDepth = ColorDepth.Depth8Bit;
            this.ContextIcons.ImageSize = new Size(0x20, 0x20);
            this.ContextIcons.TransparentColor = Color.Transparent;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x21b, 390);
            base.Controls.Add(this.tabControl1);
            base.Name = "ICMDictionary";
            this.Text = "ICMDictionary";
            this.tabControl1.ResumeLayout(false);
            this.tabCompany.ResumeLayout(false);
            this.tabCompany.PerformLayout();
            this.cmCompany.ResumeLayout(false);
            this.Dictionary.EndInit();
            base.ResumeLayout(false);
        }

        private string ShowEditWindow(string value)
        {
            using (ICMEditValueForm form = new ICMEditValueForm(value))
            {
                if (DialogResult.OK == form.ShowDialog())
                {
                    return form.Value;
                }
                return string.Empty;
            }
        }
    }
}

